
import store from '@/store'

const hasPermission = (currentPermissions) => {
	
	const value = currentPermissions
	const all_permission = "*:*:*";
	const permissions = store?.state?.user?.permissions
	
	let permissionFlag = true
	if (value && value instanceof Array && value.length > 0) {
		
		const hasPermissions = permissions.some(permission => {
			return all_permission === permission || value.includes(permission)
		})
	
		if (!hasPermissions) {
			permissionFlag = false
		}
	}
	return permissionFlag


}

export default hasPermission
